//
//  KLTextView.h
//  KLTextView
//
//  Created by PPAbner on 2020/9/3.
//

#import <UIKit/UIKit.h>
@class KLTextView;

NS_ASSUME_NONNULL_BEGIN

///KLTextView的风格
typedef NS_ENUM(NSInteger, KLTextViewStyle) {
    KLTextViewStyleMaxMinHeight = 0,   ///最大最小高度
    KLTextViewStyleMaxMinLine          ///最大最小行数
};

typedef void(^DidChangedHeightBlock)(KLTextView *textView, CGFloat height);
typedef void(^DidChangedTextBlock)(KLTextView *textView);

@interface KLTextView : UIView

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
- (instancetype)initWithFrame:(CGRect)frame style:(KLTextViewStyle)style NS_DESIGNATED_INITIALIZER;

///高度改变回调
@property (nonatomic, copy, nullable) DidChangedHeightBlock didChangedHeightBlcok;
///文字改变回调
@property (nonatomic, copy, nullable) DidChangedTextBlock didChangedTextBlcok;

///KLTextViewStyleMaxMinHeight
@property (nonatomic, assign) CGFloat maximumHeight;  ///default is 100
@property (nonatomic, assign) CGFloat minimumHeight;  ///default is 45

///KLTextViewStyleMaxMinLine
@property (nonatomic, assign) CGFloat maximumLine;  ///default is 5
@property (nonatomic, assign) CGFloat minimumLine;  ///default is 1


/////相当于UITextView的textContainerInset的top/bottom，default is 5
//@property (nonatomic, assign) CGFloat verticalMargin;
//
/////相当于UITextView的textContainerInset的top/bottom，default is 10
//@property (nonatomic, assign) CGFloat horizontalMargin;

///default is UIEdgeInsetsMake(5, 10, 5, 10);
@property(nonatomic, assign)UIEdgeInsets textContainerInset;

///「参考UITextField」default is nil
@property (nonatomic, copy, nullable) NSString *text;

///「参考UITextField」default is nil
@property (nonatomic, copy, nullable) NSAttributedString *attributedText;

///「参考UITextField」default is nil. use opaque black
@property (nonatomic, strong, nullable) UIColor *textColor;

///「参考UITextField」default is nil. use system font 12 pt
@property (nonatomic, strong, nullable) UIFont *font;

///「参考UITextField」default is nil. string is drawn 70% gray,（0x808080,0.7）or (128,128,128,0.7)
@property (nonatomic, copy, nullable) NSString *placeholder;

///default is 0x808080,0.7）or (128,128,128,0.7)
@property (nonatomic, strong, nullable) UIColor *placeholcerColor;

///「参考UITextField」default is nil.
@property (nonatomic, copy, nullable) NSAttributedString *attributedPlaceholder;


- (void)setCorcerRadius:(CGFloat)cornerRadius;

- (void)configureMaxTextCount:(NSInteger)maxTextCount font:(nullable UIFont *)font textColor:(nullable UIColor*)textColor isSingleLine:(BOOL)isSingleLine;

@end



NS_ASSUME_NONNULL_END
